<?php

/**
 * Appointment form base class.
 *
 * @method Appointment getObject() Returns the current form's model object
 *
 * @package    docplus.co.za
 * @subpackage form
 * @author     Fox Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAppointmentForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                    => new sfWidgetFormInputHidden(),
      'time_slot_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TimeSlot'), 'add_empty' => false)),
      'doctor_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Doctor'), 'add_empty' => false)),
      'member_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Member'), 'add_empty' => false)),
      'is_for_yourself'       => new sfWidgetFormInputCheckbox(),
      'is_using_insurance'    => new sfWidgetFormInputCheckbox(),
      'has_reminder'          => new sfWidgetFormInputCheckbox(),
      'appointment_reason_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('VisitReason'), 'add_empty' => false)),
      'status'                => new sfWidgetFormChoice(array('choices' => array('Cancelled' => 'Cancelled', 'Missed' => 'Missed', 'Held' => 'Held', 'Pending' => 'Pending', 'Approved' => 'Approved'))),
      'note_by_doctor'        => new sfWidgetFormTextarea(),
      'note_by_member'        => new sfWidgetFormTextarea(),
      'created_at'            => new sfWidgetFormDateTime(),
      'updated_at'            => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'time_slot_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TimeSlot'))),
      'doctor_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Doctor'))),
      'member_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Member'))),
      'is_for_yourself'       => new sfValidatorBoolean(array('required' => false)),
      'is_using_insurance'    => new sfValidatorBoolean(array('required' => false)),
      'has_reminder'          => new sfValidatorBoolean(array('required' => false)),
      'appointment_reason_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('VisitReason'))),
      'status'                => new sfValidatorChoice(array('choices' => array(0 => 'Cancelled', 1 => 'Missed', 2 => 'Held', 3 => 'Pending', 4 => 'Approved'), 'required' => false)),
      'note_by_doctor'        => new sfValidatorString(array('required' => false)),
      'note_by_member'        => new sfValidatorString(array('required' => false)),
      'created_at'            => new sfValidatorDateTime(),
      'updated_at'            => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('appointment[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Appointment';
  }

}
